home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util1 / wgrab.lha / wshotiff.c < prev    next >
C/C++ Source or Header  |  1995-10-30  |  2KB  |  82 lines

  1. /* $Id$
  2. */
  3. #include <intuition/IntuitionBase.h>
  4. #include <graphics/GfxBase.h>
  5. #include <exec/memory.h>
  6. #include <dos/dos.h>
  7.  
  8. #include <clib/intuition_protos.h>
  9. #include <clib/graphics_protos.h>
  10. #include <clib/alib_protos.h>
  11. #include <clib/exec_protos.h>
  12. #include <clib/dos_protos.h>
  13. #include <clib/macros.h>
  14.  
  15. #include <stdlib.h>
  16.  
  17. #include <libraries/iff.h>
  18.  
  19. char *MYLIBNAME="iff.library";
  20.  
  21. extern struct IntuitionBase *IntuitionBase;
  22. extern struct Library *IFFBase;
  23.  
  24. struct picdata {
  25.     struct BitMap *bitmap;
  26.     ULONG *colortable;
  27.     };
  28.  
  29. void
  30. SavePicture(Object *Picture,const STRPTR FileName)
  31. {
  32.    struct picdata *data=(struct picdata *)Picture;
  33.  
  34.    if (!IFFL_SaveBitMap(FileName,data->bitmap,(WORD *)data->colortable,1)) {
  35.        printf("Error On Saving");
  36.        }
  37.    }
  38.  
  39. Object *
  40. GetPicture(BOOL scr)
  41. {
  42.     struct picdata *data=(struct picdata *)malloc(sizeof(struct picdata));
  43.     ULONG IntuiLock;
  44.     struct Window *Window;
  45.     BOOL Locked=TRUE;
  46.     struct Screen *Screen;
  47.     LONG NumColours;
  48.  
  49.     IntuiLock=LockIBase(NULL);
  50.  
  51.     if(!scr) {
  52.         Window = IntuitionBase -> ActiveWindow;
  53.  
  54.         data->bitmap=Window->RPort->BitMap;
  55.         }
  56.     else {
  57.         Screen = IntuitionBase -> ActiveScreen;
  58.  
  59.         data->bitmap=Screen->RastPort.BitMap;
  60.         }
  61.  
  62.     NumColours = ((scr)?(Screen -> ViewPort . ColorMap -> Count):(Window -> WScreen -> ViewPort . ColorMap -> Count));
  63.  
  64.     if(data->colortable=(ULONG *)malloc(sizeof(ULONG)*3*NumColours)) {
  65.  
  66.          GetRGB32(((scr)?(Screen -> ViewPort . ColorMap):(Window -> WScreen -> ViewPort . ColorMap)),0,NumColours,
  67.          data->colortable);
  68.  
  69.          UnlockIBase(IntuiLock);
  70.  
  71.          Locked=FALSE;
  72.  
  73.          return((Object *)data);
  74.          }
  75.     }
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.